package md.lanjing.com.module_mine.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_mine.api.MineApiService;
import md.lanjing.com.module_mine.bean.UpReceiveMoneyAliRequest;
import md.lanjing.com.module_mine.bean.UpReceiveMoneyBankRequest;
import md.lanjing.com.module_mine.bean.UpReceiveMoneyTypeRequest;
import md.lanjing.com.module_mine.bean.UpReceiveMoneyTypeResponce;
import retrofit2.Call;
import retrofit2.Response;

public class UpReceiveMoneyTypeContact {
    public static class UpReceiveMoneyTypePresent extends BasePresent<IUpReceiveMoneyTypeView> {
        public void upCode(final Context context, String base64Img, int type, String cardName, String cardNum, String ownerName){
            MineApiService service= ServiceGenerator.createService(MineApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            Call<UpReceiveMoneyTypeResponce> call=null;
            switch (type){
                case 0:
                    UpReceiveMoneyAliRequest request1=new UpReceiveMoneyAliRequest(userId,base64Img);
                    call=service.upReceiveAliCode(request1);
                    break;
                case 1:
                    UpReceiveMoneyTypeRequest request2=new UpReceiveMoneyTypeRequest(userId,base64Img);
                    call = service.upReceiveWeixinCode(request2);
                    break;
                case 2:
                    UpReceiveMoneyBankRequest request3=new UpReceiveMoneyBankRequest(userId,cardName,cardNum,ownerName);
                    call=service.upReceiveBankCard(request3);
                    break;
            }

           call.enqueue(new NetCallBack<UpReceiveMoneyTypeResponce>() {
                @Override
                public void onSuccess(Call<UpReceiveMoneyTypeResponce> call, Response<UpReceiveMoneyTypeResponce> response) {
                    if (getView()!=null){
                        getView().getCodeData( response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IUpReceiveMoneyTypeView extends IBaseView {
        void getCodeData(Response<UpReceiveMoneyTypeResponce> response);
    }
}
